import request from '@/libs/http/index'

// list
export function getUserApi(params) {
  return request({
    url: '/user',
    method: 'GET',
    params
  })
}

// create
export function addUserApi(data) {
  return request({
    url: '/user',
    method: 'POST',
    data
  })
}

export function updateUserApi(data) {
  return request({
    url: '/user',
    method: 'PATCH',
    data
  })
}

export function delUserApi(id) {
  return request({
    url: `/user/${id}`,
    method: 'DELETE'
  })
}

export function detailUserApi(id) {
  return request({
    url: `/user/${id}`,
    method: 'GET'
  })
}

// 设置管理员
export function setAdminApi(data) {
  return request({
    url: '/user',
    method: 'PATCH',
    data
  })
}

// 更新用户头像
export function updateAvatarApi(data) {
  return request({
    url: '/user/avatar',
    method: 'PATCH',
    data
  })
}